home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / Programs / Virtual.CD.v5.0.2.Network.Edition.WinALL / VCD502EG.exe / Program Files / Virtual CD v5 / API / examples / VBS / VCDAPIEjectAllDrives.vbs next >
Encoding:
Text File  |  2003-02-13  |  1.5 KB  |  60 lines

  1. ' **************************************************
  2. ' *
  3. ' * VCDAPIEjectAllDrives.vbs
  4. ' *
  5. ' * Copyright 2002-2003 by H+H Software GmbH
  6. ' *
  7. ' * Virtual CD v5 API example file. 
  8. ' * Ejcet all virtual CDs currently inserted.
  9. ' *
  10. ' **************************************************
  11.  
  12. Option Explicit
  13.  
  14. DIM IApi            ' Virtual CD v5 API Object
  15. DIM strVCDDrives    ' existing virtual drives
  16. DIM strVCDImage        ' file name of a virtual CD
  17. DIM strDrive        ' single drive letter
  18. DIM iLen            ' string length
  19. DIM iRC                ' return value
  20. DIM i                ' Counter
  21. DIM strTitle        ' Dialog title
  22.  
  23. strTitle = "Virtual CD API Example (VCDAPIEjectAllDrives.vbs)"
  24.  
  25. ' Init the VCD API object
  26. Set IApi = CreateObject("Vc5api.Api")
  27.  
  28. ' Get all exisiting virtual drive letters
  29. strVCDDrives = IApi.VCDGetVCDDriveLetters
  30. iLen = Len(strVCDDrives)
  31.  
  32. ' only if there are virtual drives they need to be ejected
  33. If iLen > 0 then
  34.     
  35.     ' loop throuh the virtual drive letter
  36.     For i = 1 to iLen step 1
  37.         ' get the next drive letter and the inserted image
  38.         strDrive = Mid(strVCDDrives, i, 1)
  39.         strVCDImage = IApi.VcdGetMountedFileFromDrive(strDrive)
  40.         
  41.         ' if an image is inserted eject it
  42.         If Len(strVCDImage) > 0 Then
  43.             iRC = IApi.VCDEject(strDrive)
  44.             
  45.             ' message if an error has happend
  46.             If iRC <> 0 Then
  47.                 MsgBox "VCDEject for virtual Drive " & strDrive &": Failed (EC: " & iRC &")!", vbExclamation, strTitle
  48.             End If
  49.         End If
  50.     Next
  51.     
  52.     If iRC = 0 THen
  53.         MsgBox "All virtual CDs ejected!", vbInformation, strTitle
  54.     End If
  55. End If
  56.  
  57. Set IApi = Nothing
  58.  
  59. WScript.Quit(0)
  60.